<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Notifications\Notifiable;
use Watson\Validating\ValidatingTrait;


class WechatUser extends Model
{
    use Notifiable;
    use ValidatingTrait;
    use SoftDeletes;
    protected $table = "wechat_users";
    protected $fillable = [
        "id",
        "sex", "nick_name", "city","country","province","headimgurl","student_code",
        "open_id","subscribe_time","remark","groupid","tagid_list","w_id","deleted_at"
    ];
    public function wechat()
    {
        return $this->hasOne('App\Models\WeChat','id','w_id');
    }
    protected $rules = [
        'open_id' => 'required|unique:wechat_users'
    ];
    protected $validationMessages = [
        'open_id.required' => '用户名必填',
        'open_id.unique' => '该id已经被注册过了',
    ];
}
